package com.cloud.lan.entity.base;

import com.cloud.lan.entity.base.common.Page;

import java.io.Serializable;
import java.util.Map;

import lombok.Data;

/**
 * 分页统一入参
 * @author ErKang
 * @date Created in 2021/12/5 04:45
 * @title PageRequest.java
 * Department: Product development
 */
@Data
public class PageRequest<T> implements Serializable {

    private static final long serialVersionUID = 5798646524247574038L;

    /** 用户id */
    private Long userId;

    private T requestData;

    private Page page;

    /** 额外参数 */
    private Map<String, Object> extra;

    public T getRequestData() {
        return requestData;
    }

    public void setRequestData(T requestData) {
        this.requestData = requestData;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public Page getPage(boolean adapter) {
        if (!adapter) {
            return getPage();
        } else {
            if (null == page) {
                page = new Page();
            }
            if (page.getCurrentPage() < 1) {
                page.setCurrentPage(1);
            }
            return page;
        }
    }
}
